from PyQt5.QtCore import Qt
from PyQt5.QtSvg import QSvgWidget
from PyQt5.QtWidgets import QWidget, QMainWindow, QLabel, QGraphicsView, QGraphicsScene, QVBoxLayout
from PyQt5.QtSvg import QGraphicsSvgItem

class Widget(QWidget):
    def showType(self, isFull):
        if isFull:
            return super().showFullScreen()
        else:
            return super().show()

class Window(QMainWindow):
    def showType(self, isFull):
        if isFull:
            return super().showFullScreen()
        else:
            return super().show()

class Label(QLabel):
    def setTextOrPixmap(self, data):
        if type(data) == str:
            self.setText(data)
        else:
            self.setPixmap(data)

class SvgView(QGraphicsView):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.scale = 1
        self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
        self.setResizeAnchor(QGraphicsView.AnchorUnderMouse)
        self.scene = QGraphicsScene()
        self.setScene(self.scene)
 
    def wheelEvent(self, event):
        if event.angleDelta().y() > 0:  # Zoom in
            self.scale *= 1.1
        else:  # Zoom out
            self.scale /= 1.1
        self.svg_item.setScale(self.scale)

    def path(self, path):
        self._path = path

    def load(self, num):
        if hasattr(self, 'svg_item'):
            self.scene.removeItem(self.svg_item)
        self.svg_item = QGraphicsSvgItem(self._path)
        self.scene.addItem(self.svg_item)
        self.svg_item.setScale(self.scale)